﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Data.Linq;
using MyMoviesBrowserLibrary;

namespace TVManager
{
    [ValueConversion(typeof(object), typeof(string))]
    public class SeasonCountConverter : IValueConverter
    {
        public object Convert(object value, Type targetType,
            object parameter, System.Globalization.CultureInfo culture)
        {

            EntitySet<Episode> episodes = value as EntitySet<Episode>;
            if (episodes == null)
                return "";
            if (episodes.Where(e => !string.IsNullOrEmpty(e.FileLocation)).Count() > 0)
                return "";
            else
                return " *";
        }

        public object ConvertBack(object value, Type targetType,
            object parameter, System.Globalization.CultureInfo culture)
        {
            // we don't intend this to ever be called
            return null;
        }
    }

    [ValueConversion(typeof(object), typeof(string))]
    public class EpisdoeFileCountConverter : IValueConverter
    {
        public object Convert(object value, Type targetType,
            object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null)
                return " *";
            string fileLocation = value.ToString();
            if (!string.IsNullOrEmpty(fileLocation))
                return "";
            else
                return " *";
        }

        public object ConvertBack(object value, Type targetType,
            object parameter, System.Globalization.CultureInfo culture)
        {
            // we don't intend this to ever be called
            return null;
        }
    }
}
